﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGen.Managers.Collision;
using NGen.Managers.GameObject;
using Microsoft.Xna.Framework;
using NGen.Systems.StringAlarms;
using Microsoft.Xna.Framework.Graphics;
using NGen;

namespace Psych.Objects.Character
{
    class GameObjectPunch : GameObject2D, ICollidable2D, IAlarmListener
    {
        private BoundingBox m_boundingBox;
        protected AlarmSystem punchAlarm;
        protected bool attackReady = true;
        private double attackDelay = 0.1;
        private Texture2D m_insanityTexture1;


        protected override void _Initialize()
        {
            punchAlarm = new AlarmSystem();
            m_boundingBox = new BoundingBox(new Vector3(), new Vector3(50, 50, 1.0f));

            m_insanityTexture1 = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instable tic_01");

            base._Initialize();
        }

        protected override void _Draw(GameTime p_gameTime)
        {
            GameEngine.SpriteBatch.Draw(m_insanityTexture1, new Rectangle((int)m_position.X,(int) m_position.Y, 160, 160), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .5f);
            base._Draw(p_gameTime);
        }

        public Microsoft.Xna.Framework.BoundingBox BoundingBox
        {
            get { return m_boundingBox; }
            set { }
        }

        public void Collided(CollisionMessage2D p_objectCollidedWith)
        {

        }

        public virtual void OnAlarmEvent(string p_message)
        {

            switch (p_message)
            {
                case "destroySelf":
                    GameEngine.GetService<IManagerCollision2D>().UnRegisterCollidable(Id);
                    Destroy(Id);
                    break;
            }
        }

        protected override void _Update(GameTime p_gameTime)
        {
            punchAlarm.Update(p_gameTime);
            

                punchAlarm.Add(new AlarmObject(this, attackDelay, "destroySelf"));
            
            base._Update(p_gameTime);
        }

        
    }
}
